<?php
// $_SESSION['content_id'] = empty($_GET['id']) ? 0 : $_GET['id'];
$web_id = empty($_GET['id']) ? 0 : $_GET['id'];
require_once "config.php";
require_once "weixin_info.php";
require_once "jssdk.php";
$jssdk = new JSSDK("", "");
$signPackage = $jssdk->GetSignPackage();
$next = "";
$pre = "";
if (!isset($_SESSION['content_id']) || empty($_SESSION['content_id'])) {
    Header("location:index.php");

    // $id=$_GET['id'];
    // $sql = $mysql->query("select * from dyspw_weblink where id=$id");die;

    // $rows = $sql->fetch_all(MYSQLI_ASSOC);

    // $next = "content.php?id={$rows[1]['id']}"; //当前ID赋值给下一页

} else {
    $id = $_SESSION['content_id'];
    // $id = $_GET['id'];
    $uid = $_SESSION['Member_info'][0]['id'];
    $sql = $mysql->query("select history,history_time from dyspw_member where id=" . $uid);
    $u_info = $sql->fetch_all(MYSQLI_ASSOC);
    $history_time = $u_info[0]['history_time'];
    $history = $u_info[0]['history'];
    //查出浏览量高到低下一个
    $sql = $mysql->query("select * from dyspw_weblink where id={$id}");
    $if_rows = $sql->fetch_all(MYSQLI_ASSOC);
//    if ($if_rows[0]['checkinfo'] == 'true') {
        $rows = $if_rows;
//    }
    //更新用户偏好分类
    $query = ("UPDATE dyspw_member SET pianhao=" . $rows[0]['classid'] . " WHERE ID=" . $uid);
    $mysql->query($query);

    //更新用户观看历史记录
    //1.确定是否需要重置观看记录
    $now_time = time();
    if (($now_time - $history_time) > 129600) { //超过15天，重置观看历史
        $his_arr = array();
        array_push($his_arr, $id);
        $his_str = implode(",", $his_arr);
        $query = ("UPDATE dyspw_member SET history='" . $his_str . "',history_time=" . $now_time . " WHERE ID=" . $uid);
        $mysql->query($query);
    } else { //不超过15天，更新观看历史
        $his_arr = explode(',', $history);
        array_push($his_arr, $id);
        $his_arr = array_unique($his_arr, SORT_REGULAR);
        $his_str = implode(',', $his_arr);
        $query = ("UPDATE dyspw_member SET history='" . $his_str . "' WHERE ID=" . $uid);
        $mysql->query($query);
    }
    //

    $mem_sql = $mysql->query("select * from dyspw_member where id=" . $rows[0]['u_id']);
    $member = $mem_sql->fetch_all(MYSQLI_ASSOC);
    //查出浏览量比上一个低的
    $next_sql = $mysql->query("select * from dyspw_weblink where checkinfo='true' and  hits <= {$rows[0]['hits']}  and id <> {$rows[0]['id']} order by hits desc limit 1");
    $next_rows = $next_sql->fetch_all(MYSQLI_ASSOC);

    if (!empty($next_rows)) {
        $next = "content.php?id={$next_rows[0]['id']}";
    }


    $pre_sql = $mysql->query("select * from dyspw_weblink where checkinfo='true' and  hits >= {$rows[0]['hits']}  and id <> {$rows[0]['id']} order by hits asc limit 1");
    $pre_rows = $pre_sql->fetch_all(MYSQLI_ASSOC);


    if (!empty($pre_rows)) {
        $pre = "content.php?id={$pre_rows[0]['id']}";
    }
    $id = $rows[0]['id'];
    $web_id = $rows[0]['id'];
    $uid = $_SESSION['Member_info'][0]['id'];

    //评论
    $user_conment = $mysql->query("select * from dyspw_usercomment where aid={$web_id}");
    $comment_rows = $user_conment->fetch_all(MYSQLI_ASSOC);
    $conment_sum = count($comment_rows);

    //评论回复
    if (empty($comment_rows)) {
        $m_c_rows['conment'] = '';
    } else {


        //评论回复
        foreach ($comment_rows as $kk => $vv) {
            $m_c_rows['conment'][$kk] = $vv;
            $conmentlike_sql = $mysql->query("select * from dyspw_conment_like where u_id={$uid} and conment_id='{$vv['id']}'");
            $conmentlike_rows = $conmentlike_sql->fetch_all(MYSQLI_ASSOC);

            if (empty($conmentlike_rows)) {
                $m_c_rows['conment'][$kk]['like_state'] = 0;
            } else {
                $m_c_rows['conment'][$kk]['like_state'] = $conmentlike_rows[0]['state'];
            }

            $user_message = $mysql->query("select * from dyspw_message where c_id={$vv['id']}");
            $message_rows = $user_message->fetch_all(MYSQLI_ASSOC);
            if (empty($message_rows)) {
                $m_c_rows['conment'][$kk]['message'] = '';
            } else {
                foreach ($message_rows as $m_k => $m_v) {
                    $m_c_rows['conment'][$kk]['message'][$m_k] = $m_v;
                }
                $m_c_rows['conment'][$kk]['message_sum'] = count($message_rows);
            }
        }
    }


    //点赞状态
    $user_like = $mysql->query("select * from dyspw_like where uid={$uid} and weblinkid=$web_id");
    $like_rows = $user_like->fetch_all(MYSQLI_ASSOC);
    if ($like_rows) {
        $like_state = $like_rows[0]['state'];
    } else {
        $like_state = 0;
    }

    //收藏状态
    $user_userfavorite = $mysql->query("select * from dyspw_userfavorite where uid={$uid} and aid=$web_id");
    $userfavorite_rows = $user_userfavorite->fetch_all(MYSQLI_ASSOC);

    if ($userfavorite_rows) {
        $userfavorite_state = $userfavorite_rows[0]['isshow'];
    } else {
        $userfavorite_state = 0;
    }
}
    // print_r($rows);

//判定视频是否有背景图，若为空则下载截取图片上传到服务器插入数据库
if (empty($rows[0]['picurl'])) {
    $url = $rows[0]['linkurl'] . "?vframe/jpg/offset/1/w/368/h/640/rotate/auto";
    $path = "xiaochengxu/uploads/picimg/";
    $userid = $rows[0]['id'];
    // $url = "http://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLvRT0Hxy8MLXmpCORnzh68yicY4ibMOuhuzNkcCqibwEXWrA8B47GZPCZgU6a6hgQeMibbY1NSeFq6yQ/132";
    $header = [
        'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0',
        'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
        'Accept-Encoding: gzip, deflate',
    ];
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
    curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
    $data = curl_exec($curl);
    $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    curl_close($curl);
    // echo $code;exit;
    if ($code == 200) { //把URL格式的图片转成base64_encode格式的！
        $imgBase64Code = "data:image/jpeg;base64," . base64_encode($data);
    }
    $img_content = $imgBase64Code;
    // echo $img_content;exit;
    if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $img_content, $result)) {
        $type = $result[2]; //得到图片类型png jpg gif
        //相对路径
        $relative_path = $path;
        //绝对路径（$_SERVER['DOCUMENT_ROOT']为网站根目录）
        $absolute_path = $_SERVER['DOCUMENT_ROOT'] . $relative_path;
        if (!file_exists($absolute_path)) {
            //检查是否有该文件夹，如果没有就创建，并给予最高权限
            mkdir($absolute_path, 0700);
        }
        //文件名
        $filename = time() . $userid . ".{$type}";
        $new_file = $absolute_path . $filename;
        // echo $new_file;exit;
        if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $img_content)))) {
            $picurl = "https://5p8.fyh5p8.com/" . $relative_path . $filename;
            $goods_add = $mysql->query("UPDATE dyspw_weblink SET picurl='{$picurl}' where id={$rows[0]['id']}");
            $rows_sql = $mysql->query("select * from dyspw_weblink where id={$rows[0]['id']}");
            $rows = $rows_sql->fetch_all(MYSQLI_ASSOC);
        }
    }
}


$row_sql = $mysql->query("select * from dyspw_member where id = " . $rows[0]['u_id']);
$row_member = $row_sql->fetch_all(MYSQLI_ASSOC);
$row_member[0]['id'] = empty($row_member[0]['id']) ? 0 : $row_member[0]['id'];
$follow_sql = $mysql->query("select * from dyspw_follow where fans_id = {$_SESSION['Member_info'][0]['id']} and u_id = {$row_member[0]['id']}"); //是否关注
$follow = $follow_sql->fetch_all(MYSQLI_ASSOC);
/* /*if(!empty($member)){if($member[0]['is_vip'] > 0 ){*/  //立即购买可见权限*/
$share_sql = $mysql->query("select * from dyspw_share where u_id = {$_SESSION['Member_info'][0]['id']} and web_id = {$rows[0]['id']}");
$share = $share_sql->fetch_all(MYSQLI_ASSOC); //分享信息获取
// print_r($share);

// echo $rows[0]['linkurl']."?vframe/jpg/offset/1/w/50/h/50/rotate/auto";exit;


$up = $mysql->query("update dyspw_weblink set hits=hits+1 where id=$id");
?>

<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <title>内容</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta name="format-detection" content="telephone=yes"/>
    <link rel="stylesheet" href="css/core.css?version=1.8">
    <link rel="stylesheet" href="css/editStyle.css?version=1.8">
    <!-- <link href="js/layer/need/layer.css" rel="stylesheet" /> -->
    <link href="//cdn.bootcss.com/layer/3.0.1/skin/default/layer.css" rel="stylesheet">
    <script src="js/jquery-2.2.4.min.js" type="text/javascript"></script>
    <script src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
    <script src="js/jquery.cookie.js" type="text/javascript"></script>
    <script src="js/app-login.js" type="text/javascript"></script>
    <!-- <script src="js/layer/layer.js" type="text/javascript"></script> -->
    <script src="//cdn.bootcss.com/layer/3.0.1/layer.min.js"></script>
    <script src="js/clipboard.min.js"></script>
    <script src="js/dsbridge.js" type="text/javascript"></script>

    <style>
        .roomNumber {
            height: 35px !important;
            line-height: 35px !important;
            border: none;
            border-bottom: 1px solid #777;
        }

        .layui-layer-title,
        .layui-layer-btn .layui-layer-btn0 {
            background: linear-gradient(to bottom, #fb7e76, #ff0202);
            color: #FFF;
        }

        .layui-layer-btn .layui-layer-btn0 {
            border-color: #ff0202
        }

        .layui-layer-page .layui-layer-content {
            padding: 30px 20px;
        }

        #putWindow>div {
            line-height: 35px;
            border-radius: 10px;
            text-align: center;
            color: #000;
            font-size: 16px;
            background: linear-gradient(to bottom, #fb7e76, #ff0202);
            color: #FFF;
            margin: 10px 0;
        }
    </style>
    <script>
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?cb5d49b07e0a753dc8ee27ba2c73495d";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>
</head>

<body style="overflow: hidden;">
    <!--此图片必须放在body标签的最前面，且高度必须为屏幕宽度的80%  -->
    <img src="" style="position:absolute; top:0; left:0;width: 30px;height:30px;z-index:-1;opacity: 0; " class="iiimg">


    <section class="video-content" style="height:100%;background:#000;overflow-y: auto;">
        <div class="video-user-info">
            <a href="index.php" class="back"><img src="images/back.png" style="    margin-top: 20px;" /></a>
            <div class="user-box">
                <div class="" style="display: inline-block;position: relative;width: 60px;height: 60px;">
                    <img src="<?php echo $rows[0]['avatar'] ?>" class="avatar" />
                    <?php if (empty($follow)) { ?>
                        <em><img id="add" class="follow" src="images/follow.png" alt="" style="width: 25px;position: absolute;left: 12px;top: 42px;"></em>
                    <?php
                    } else { ?>
                        <em><img id="delete" class="follow" src="images/unfollow.png" alt="" style="width: 25px;position: absolute;left: 12px;top: 42px;"></em>
              <?php }?>
                </div>
                <a href="member.php?id=<?php echo $rows[0]['u_id'] ?>">
                    <div style="width: 50%;display: inline-block;overflow: hidden;height:50px;">
                        <h2 style="line-height:25px;"><?php echo $rows[0]['webname'] ?></h2>
                        <p><?php echo $rows[0]['webnote'] ?></p>
                    </div>
                </a>
                <!-- <i class="follow"><?php if (empty($follow)) {
                                            echo '+关注';
                                        } else {
                                            echo '已关注';
                                        } ?></i> -->
                <a href="https://5p8.fyh5p8.com/xiaochengxu/index.php" style="height: 60px;display: inline-block;float: right;"><img src="images/logo.png" class="logo" style="    margin-top: 10px;" /></a>
            </div>
        </div>
        <div class="video-right-box">
            <ul>
                <li><a href="index.php"><img src="images/home.png" /><br />首页</a></li>
                <li class="BindShare"><a href="javascript:void(0);"><img src="images/share.png" /><br />分享内容编辑</a></li>
                <li class="BindGive"><a href="javascript:void(0);">
                        <?php if ($like_state == 1) { ?>
                            <img src="images/give_r.png" />
                        <?php
                        } else { ?>
                            <img src="images/give.png" alt="">
                        <?php
                        } ?>
                        <br />点赞 <span id="tbd"><?php echo $rows[0]['zan'] ?></span></a>
                </li>
                <li class="BindComment"><a href="javascript:void(0);"><img src="images/comment.png" /><br />点击评论</a>
                </li>
                <li class="BindCollection"><a href="javascript:void(0);">
                        <?php if ($userfavorite_state == 1) { ?>
                            <img src="images/collection_r.png" alt="">
                        <?php
                        } else { ?>
                            <img src="images/collection.png" />
                        <?php
                        } ?>
                        <br />点击收藏</a>
                </li>
                <?php if ($row_member[0]['is_vip'] == 2 || $row_member[0]['is_vip'] == 3) { ?>
                    <li class='BindContact'><a href='javascript:void(0);'><img src='images/wechat.png' /><br />联系我</a></li>
                <?php
                } ?>
                <li class='other_btn'><a href='javascript:void(0);'><img src='images/other_icon.png' /><br />其他</a></li>

            </ul>
        </div>
        <div class="video-bottom-box">

            <div class="video-bottom-desc cl">
                <i style="display:inline-block;float:left;width:55%;"><span id="address"></span>距离你 <span class="juli"></span> </i>
                <div class="" style="display:inline-blobk; float:right;">
                    <a href="fenlei.php" style="float:right;margin-left: 5px;">进入分类</a>
                    <?php if ($row_member[0]['is_vip'] == 2) { ?>
                        <a style="float:right;" href="http://fyh5p8.fyh51.com/addons/we7_wmall/template/vue/index.html?menu=&from=groupmessage#/pages/store/share?sid=1316&i=1">立即了解</a>
                    <?php
                    } elseif ($row_member[0]['is_vip'] != 0) { ?>
                        <?php if(!empty($if_rows[0]['goods_id']) && $if_rows[0]['goods_id'] != 0){ ?>
                            <a style="float:right;" href="goods_info.php?id=<?php echo $if_rows[0]['goods_id']; ?>&u_id=<?php echo $if_rows[0]['u_id']; ?>">立即购买</a>
                        <?php }else{ ?>
                            <a style="float:right;" href="mem_goods.php?id=<?php echo $row_member[0]['id']; ?>">立即购买</a>
                        <?php } ?>
                    <?php
                    } ?>
                </div>
            </div>

            <div class="video-bottom-input cl">
                <em>留下你的精彩评论吧~~~~</em>
                <i class="btn-video-mail"><img src="images/mail.png" /></i>
                <i class="btn-video-smile"><img src="images/smile.png" /></i>
            </div>

        </div>
        <div class="play"><img src="images/play.png" /></div>
        <img src="<?php echo $rows[0]['linkurl'] . "?vframe/jpg/offset/1/w/368/h/640/rotate/auto" ?>" class="video-img" style="height:auto;transform: translateY(-50%);    top: 50%;" />
        <video id="video_info" preload="auto" src="<?php echo $rows[0]['linkurl'] ?>" page-gesture="true" x5-playsinline="" playsinline="" webkit-playsinline="" show-fullscreen-btn="false" show-center-play-btn="true" show-play-btn="false" enable-play-gesture="true" loop>你的浏览器不支持HTML5播放此视频</video>
        <!-- <video id="video_info" preload="auto" style="height: 100%;width: 100%; z-index: inherit; object-fit: fill;" src="<?php echo $rows[0]['linkurl'] ?>" page-gesture="true" x5-playsinline="" playsinline="" webkit-playsinline="" show-fullscreen-btn="false" x5-video-player-type="h5" x5-video-player-fullscreen="true" show-center-play-btn="true" show-play-btn="false" enable-play-gesture="true" loop>你的浏览器不支持HTML5播放此视频</video> -->

        <!-- <video class="video-js vjs-default-skin"style="height: 100%;position: fixed;width: 100%; z-index: inherit; object-fit: fill;"x5-video-player-type="h5" x5-video-player-fullscreen="true"> -->
        </video>



        <div class="comment-info-box" style="z-index:100;">
            <h3><span id="conment-number"><?php echo $conment_sum ?></span>条评论</h3>
            <div class="comment-item-box">
                <div class="comment-item-inner" id="main-body-reply">
                    <?php if (!empty($m_c_rows['conment'])) { ?>
                        <?php foreach ($m_c_rows['conment'] as $k => $v) { ?>
                            <div class="comment-item-list">
                                <div class="comment-item-primary">
                                    <img class="comment-avatar" src="<?php echo $v['uimage'] ?>" alt="test">
                                    <ul class="comment-content">
                                        <li class="comment-content-top"><?php echo $v['uname'] ?></li>
                                        <li class="comment-content-bottom"><?php echo $v['body'] ?></li>
                                    </ul>
                                    <ul class="comment-operat">
                                        <li id="<?php echo $v['id'] ?>" class="comment_link comment-operat-share">
                                            <?php if ($v['like_state'] == 1) { ?>
                                                <img src="images/give_r.png" alt="">
                                            <?php
                                            } else { ?>
                                                <img src="images/give_b.png" />
                                            <?php
                                            } ?>
                                            <b class="conment_like<?php echo $v['id'] ?>"></b>
                                        </li>
                                        <li class="comment-operat-reply"><span>回复</span></li>
                                    </ul>
                                </div>
                                <div class="comment-item-reply">
                                    <div class="reply-content">
                                        <?php if (!empty($v['message'])) { ?>
                                            <?php foreach ($v['message'] as $m_k => $m_v) { ?>
                                                <?php if (!empty($m_v)) { ?>
                                                    <div class="comment-item-primary">
                                                        <img class="comment-avatar-small" src="./images/1.jpg" alt="test">
                                                        <ul class="comment-content">
                                                            <li class="comment-content-top"><?php echo $m_v['recont'] ?></li>
                                                            <li class="comment-content-bottom"><?php echo $m_v['recont'] ?></li>
                                                        </ul>
                                                    </div>
                                                <?php
                                                } ?>
                                            <?php
                                            } ?>
                                        <?php
                                        } ?>
                                    </div>
                                    <div class="reply-operat">
                                        <?php if (!empty($v['message_sum'])) { ?>
                                            —— 展开<?php echo $v['message_sum'] ?>条回复
                                        <?php
                                        } ?>
                                    </div>
                                </div>
                            </div>
                        <?php
                        } ?>
                    <?php
                    } ?>
                </div>
            </div>
            <!-- <ul class="cl">
                <?php if (!empty($m_c_rows['conment'])) { ?>
                <?php foreach ($m_c_rows['conment'] as $k => $v) { ?>
                    <li class="cl">
                        <div class="comment-left-box">
                        <span id="conment">
                            <img src="<?php echo $v['uimage'] ?>" />
                            <h2><?php echo $v['uname'] ?></h2>
                            <p><?php echo $v['body'] ?></p>
                        </span>
                            <?php if (!empty($v['message_sum'])) { ?>
                                <i class="arrow-down">展开<?php echo $v['message_sum'] ?>条回复</i>
                            <?php
                            } ?>
                        </div>
                        <div class="comment-right-box">
                            <em id="<?php echo $v['id'] ?>" class="comment_link">
                            <span id="c_img">
                                <?php if ($v['like_state'] == 1) { ?>
                                    <img src="images/give_r.png" alt="">
                                <?php
                                } else { ?>
                                    <img src="images/give_b.png" />
                                <?php
                                } ?>
                            </span>
                                <b class="conment_like<?php echo $v['id'] ?>"></b></em>
                            <div class="crb-list">
                                <i><span id="huifu">回复</span></i>
                            </div>
                        </div>
                        <div class="comment-huifu-box">
                            <ul class="cl">
                                <?php if (!empty($v['message'])) { ?>
                                    <?php foreach ($v['message'] as $m_k => $m_v) { ?>
                                        <li class="cl">
                                            <div class="comment-left-box">
                                                <?php if (!empty($m_v)) { ?>
                                                    <img src="images/avatar.png" />
                                                    <h2><?php echo $m_v['recont'] ?></h2>
                                                    <p><?php echo $m_v['recont'] ?></p>
                                                <?php
                                                } ?>
                                            </div>
                                            <div class="comment-right-box">
                                                <em class="message_link"><img src="images/give_b.png" /><b>6w5</b></em>
                                            </div>
                                        </li>
                                    <?php
                                    } ?>
                                <?php
                                } ?>
                            </ul>
                        </div>
                    </li>
                    <?php
                    } ?>
                <?php
                } ?>
            </ul> -->
            <div class="comment-footer-box">
                <div class="comment-input-box cl">
                    <input type="text" placeholder="留下你的精彩评论吧~~~~" class="input-comment" />
                    <i class="btn_mail"></i>
                    <i class="btn_smile"></i>
                    <i class="btn_comment"></i>
                </div>
                <div class="feel-btn-box">
                    <ul class="cl">
                        <li><img src="images/btn_feel.png" /></li>
                        <li><img src="images/btn_coll.png" /></li>
                        <li><img src="images/btn_gif.png" /></li>
                    </ul>
                </div>
            </div>
            <div class="mail-box" style="display:none;">
                <p><label><i></i>评论并转发</label></p>
                <div class="mail-list-box">
                    <ul class="cl">
                        <li><img src="images/avatar.png" />愤怒的小鸟</li>
                        <li><img src="images/avatar.png" />愤怒的小鸟</li>
                        <li><img src="images/avatar.png" />愤怒的小鸟</li>
                    </ul>
                </div>
            </div>
        </div>
        </div>
        </div>
        <div class="contact-info-box contact-info-box-act" style="z-index:101;">
            <ul class="cl">
                <?php if ($_SERVER['HTTP_USER_AGENT'] == 'AndroidNative' || $_SERVER['HTTP_USER_AGENT'] == 'IosNative') { ?>
                    <li style="color: #00bf00;" data-type="dh"><span class="toPhone"><img src="images/icon_phone.png" /><br />电话</span></li>
                    <?php
                    } else { ?>
                    <li style="color: #00bf00;" data-type="dh"><a href="tel:<?php echo $row_member[0]['mobile'] ?>"><img src="images/icon_phone.png" /><br />电话</a></li>
                <?php }?>
                <li style="color: #00bf00;" data-type="wx" class="copy_wx" data-clipboard-text="<?php echo $row_member[0]['wxnum'] ?>"><img src="images/icon-wechat.png" /><br />微信</li>
                <li data-type="sx"><img src="images/lxw04.png" /><br />私信</li>
                <li style="color: #00bf00;" data-type="ydylt"><img src="images/onetoone.png" /><br />一对一聊天</li>
            </ul>
        </div>
        <div class="contact-info-box other-box" style="z-index:102;">
            <ul class="cl">
                <li onclick="report_ajax('jubao');"><img src="images/report_icon.png" /><br />举报</li>
                <li onclick="report_ajax('tousu');"><img src="images/complaint_icon.png" /><br />投诉</li>
                <li onclick="report_ajax('lahei');"><img src="images/block_icon.png" /><br />拉黑</li>
            </ul>
        </div>
        <div class="other_con" style="position: fixed;z-index: 103;top: 50%;left: 50%;width: 80%;background: #fff;transform: translate(-50%,-50%);border-radius: 10px;display:none;">
            <h4 data_obj="" style="padding: 10px 10px;font-size: 16px;font-weight: 600;"> 举报反馈</h4>
            <textarea name="other_con" rows="8" cols="80" style="    width: 80%;display: block;border-radius: 5px;margin: auto;height: 100px;"></textarea>
            <span class="feedback" style="width: 80px;line-height: 30px;display: block;text-align: center;margin: 10px auto;color:#fff;background: #405ed8;border-radius: 5px;">提交</span>
        </div>
    </section>

    <!-- 编辑窗口 start -->
    <div class="box-curtain">cfw</div>
    <div class="share-info-box">
        <h2>分享内容编辑</h2>
        <div class="form">
            <!-- 图片上传 start-->
            <div class="form-item" style="width: 100px;height: 140px;overflow:hidden;display: flex;justify-content: center;flex-flow: column;">
                <div class="fileDiv">
                    <div class="filebox" onclick="upFile();">
                        <img src="" alt="上传图片" id="fileImg">
                        <!-- <input type="hidden" name="share_img" value="" class="hideInput" onchange="changepic(this)"> -->
                    </div>
                </div>
                <div onclick="upFile();" class="reloadDiv">
                    <span>点击替换图片</span>
                </div>
                <!-- 隐藏域 -->
                <input type="file" id="file" class="filepath" onchange="changepic(this)" accept="image/jpg,image/jpeg,image/png,image/PNG" hidden>
                <canvas id="canvas" style="display: none;"></canvas>
            </div>
            <!-- 图片上传 end-->

            <div class="rightbox">
                <div class="form-item">
                    <input type="text" name="title" value="" class="title-input" placeholder="">
                </div>
                <div class="form-item">
                    <textarea rows="4" class="desc-input" placeholder=""></textarea>
                </div>
            </div>
        </div>
        <?php if ($_SERVER['HTTP_USER_AGENT'] == 'AndroidNative' || $_SERVER['HTTP_USER_AGENT'] == 'IosNative') { ?>
            <input type="submit" value="分享" class="save">
            <?php
            } else { ?>
            <input type="submit" value="保存" class="save">
        <?php }?>
    </div>
    <!-- 编辑窗口 end -->

    <!-- 一对一聊天提交弹窗 -->
    <div id="putWindow" style="display: none;">
        <!-- <input type="text" name="roomInput" placeholder="请输入房间号" class="roomNumber"> -->
        <div onclick="joinRTCRoom(0)">语音通话</div>
        <div onclick="joinRTCRoom(1)">视频通话</div>
    </div>


    <script type="text/javascript" src="//webapi.amap.com/maps?v=1.4.1&key=fedad41056b27c3e8cc5eaca216434e9"></script>
    <script type="text/javascript">
        //禁止微信页面下拉
        document.body.addEventListener('touchmove', function(e) {
            e.preventDefault()
        }, {
            passive: false
        })

        var file = ''; //图片文件名
        var aaa;
        var _img = '',
            target_width = '',
            target_height = ''; //压缩后图片宽高

        var _title = '',
            share_desc = '',
            _imgURL = '',
            _link = ''; //需要分享的信息
        var o_title = '<?php echo $rows[0]['webname']; ?>', //视频标题
            o_imgurl = '<?php echo $rows[0]['picurl']; ?>', //视频缩略图 echo !empty($v['picurl'])?$v['picurl']:($v['linkurl']."?vframe/jpg/offset/1/w/230/h/260/rotate/auto")
            o_desc = '<?php echo $rows[0]['webnote']; ?>', //视频描述
            o_link = 'content.php?id=<?php echo $rows[0]['id']; ?>'; //视频链接   如果都用指定的同一个 就用一个变量吧

        var n_title = '<?php if (!empty($share)) { echo $share[0]['title'];} ?>', //需要分享的标题
            n_imgurl = '<?php if (!empty($share)) { echo $share[0]['img_url'];} ?>', //需要分享的缩略图
            n_desc = '<?php if (!empty($share)) { echo $share[0]['desc'];} ?>', //需要分享的描述
            n_link = 'content.php?id=<?php echo $rows[0]['id']; ?>'; //需要分享的链接
            console.log(n_title);
        if (n_title != '') {
            document.title = n_title;
            _title = document.title;
            var meta = document.getElementsByTagName('meta');
            for (i in meta) {
                if (typeof meta[i].name != "undefined" && meta[i].name.toLowerCase() == "description") {
                    share_desc = meta[i].content;
                    share_desc = n_desc; //自定义描述
                }
            }
            _imgURL = n_imgurl; //自定义图片
            _link = n_link; //链接
        } else {
            document.title = o_title;
            _title = document.title;
            var meta = document.getElementsByTagName('meta');
            for (i in meta) {
                if (typeof meta[i].name != "undefined" && meta[i].name.toLowerCase() == "description") {
                    share_desc = meta[i].content;
                    share_desc = o_desc; //自定义描述
                }
            }
            _imgURL = o_imgurl; //自定义图片
            _link = o_link; //链接
            _desc = o_desc; //链接
        }

        // console.log(_imgURL);
        // console.log(_desc);

        $('.iiimg').attr('src', _imgURL);
        //编辑框数据
        $('#fileImg').attr('src', _imgURL);
        $('.title-input').attr('placeholder', _title);
        $('.desc-input').attr('placeholder', share_desc);
        // $('.desc-input').val(share_desc);

        $(function() {
            //关注
            $(".follow").click(function() {
                var fans_id = "<?php echo $_SESSION['Member_info'][0]['id']; ?>";
                var fans_name = "<?php echo $_SESSION['Member_info'][0]['username']; ?>";
                var fans_avatar = "<?php echo $_SESSION['Member_info'][0]['avatar']; ?>";
                var u_id = "<?php echo $row_member[0]['id']; ?>";
                var u_name = "<?php echo $row_member[0]['username']; ?>";
                var u_avatar = "<?php echo $row_member[0]['avatar']; ?>";
                // console.log(fans_id, fans_name, fans_avatar, u_id, u_name, u_avatar);
                if (fans_id == u_id) {
                    return layer.open({
                        content: "您不可以关注自己哦",
                        skin: 'msg',
                        time: 3
                    });
                }
                var id = $(this).attr('id');
                const self = this;
                if (id === 'add') { //关注
                    $.ajax({
                    url: 'follow_ajax.php',
                    data: {
                        'fans_id': fans_id,
                        'fans_name': fans_name,
                        'fans_avatar': fans_avatar,
                        'u_id': u_id,
                        'u_name': u_name,
                        'u_avatar': u_avatar
                    },
                    dataType: 'json',
                    type: 'post',
                    success: function(res) {
                        if (res.status == 'y') {
                            self.src = 'images/unfollow.png';
                            return layer.open({
                                content: res.info,
                                skin: 'msg',
                                time: 3
                            });
                        } else {
                            return layer.open({
                                content: res.info,
                                skin: 'msg',
                                time: 3
                            });
                        }
                    }
                })
                } else if (id === 'delete') { // 取消关注
                    $.ajax({
                    url: 'XXXXX.php',
                    data: {
                    },
                    dataType: 'json',
                    type: 'post',
                    success: function(res) {
                        if (res.status == 'y') {
                            self.src = 'images/follow.png';
                            return layer.open({
                                content: res.info,
                                skin: 'msg',
                                time: 3
                            });
                        } else {
                            return layer.open({
                                content: res.info,
                                skin: 'msg',
                                time: 3
                            });
                        }
                    }
                })
                }

            })

            getaddre();

            wx.config({
                debug: false,
                appId: '<?php echo $signPackage["appId"]; ?>',
                timestamp: '<?php echo $signPackage["timestamp"]; ?>',
                nonceStr: '<?php echo $signPackage["nonceStr"]; ?>',
                signature: '<?php echo $signPackage["signature"]; ?>',
                jsApiList: [
                    // 所有要调用的 API 都要加到这个列表中
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage',
                    'showAllNonBaseMenuItem',
                    'updateAppMessageShareData'
                ]
            });
            wx.showAllNonBaseMenuItem();
            wx.ready(function() {
                wx.onMenuShareAppMessage({
                    // link: _link,
                    link: '',
                    imgUrl: _imgURL,
                    desc: share_desc,
                    title: _title,
                    success: function(data) {
                        //alert('分享完成!')
                    },
                    cancel: function() {}
                });
            });


            /*判断手机端左滑右滑动*/
            $("body").on("touchstart", function(e) {
                startX = e.originalEvent.changedTouches[0].pageX,
                    startY = e.originalEvent.changedTouches[0].pageY;

            });

            $("body").on("touchend", function(e) {
                var _con = $('.video-img'); // 设置目标区域
                var _convideo = $('#video_info'); // 设置目标区域
                if ((_con.is(event.target) && _con.has(event.target).length === 0) || (_convideo.is(event
                        .target) && _convideo.has(event.target).length === 0)) { // Mark 1
                    moveEndX = e.originalEvent.changedTouches[0].pageX,
                        moveEndY = e.originalEvent.changedTouches[0].pageY,
                        X = moveEndX - startX,
                        Y = moveEndY - startY;

                    if (X > 100) { //左滑
                        location.href = 'index.php';
                    } else if (X < -100) { //右滑
                        location.href = 'fenlei.php?id=<?php echo $_GET['
                    id '] ?>';
                    } else if (Y > 100) { //下滑
                        location.href = '<?php echo $pre ?>';
                    } else if (Y < -100) { //上滑
                        location.href = '<?php echo $next ?>';
                    }
                }
            });

            $(".play").click(function() {
                $(".video-img").hide();
                var video = document.querySelector('#video_info');
                video.display = 'block';
                video.play();
                $(this).hide();
                // $('.video-right-box').hide();
                // $('.video-bottom-box').hide();
            });

            $("#video_info").click(function() {

                if ($(this).hasClass("pause")) {
                    $(".play").hide();
                    // $('.video-right-box').hide();
                    // $('.video-bottom-box').hide();
                    $(this).removeClass("pause").trigger("play");
                } else {
                    $(".play").show();
                    $('.video-right-box').show();
                    $('.video-bottom-box').show();
                    $(this).addClass("pause").trigger("pause");
                }
            });

            //评论提交
            $(".btn_comment").click(function() {
                var txt = $(".input-comment").val();
                if (txt == '') {
                    return layer.open({
                        content: "请输入您的评论",
                        skin: 'msg',
                        time: 3
                    });
                }
                var aid = "<?php echo $web_id ?>";
                $.ajax({
                    url: 'userconment.php',
                    data: {
                        aid: aid,
                        txt: txt
                    },
                    dataType: 'json',
                    type: 'post',
                    success: function(data) {
                        console.log(data.rows.uname)
                        layer.open({
                            content: "发送成功",
                            skin: 'msg',
                            time: 3
                        });

                        var replyStr = `<div class="comment-item-list">
                                <div class="comment-item-primary">
                                    <img class="comment-avatar" src="${data.rows.uimage}" alt="test">
                                    <ul class="comment-content">
                                        <li class="comment-content-top">${data.rows.uname}</li>
                                        <li class="comment-content-bottom">${data.rows.body}</li>
                                    </ul>
                                    <ul class="comment-operat">
                                        <li id="${data.rows.id}" class="comment_link comment-operat-share">
                                            <img src="images/give_b.png" />
                                            <b class="conment_like${data.rows.id}"></b>
                                        </li>
                                        <li class="comment-operat-reply"><span>回复</span></li>
                                    </ul>
                                </div>
                                <div class="comment-item-reply">
                                    <div class="reply-content">
                                    </div>
                                    <div class="reply-operat">
                                    </div>
                                </div>
                            </div>`
                        // var str = ""
                        // var m_img = ""
                        // var huifu = ""
                        // str += "<img src=" + data.rows.uimage + ">"
                        // str += "<h2>" + data.rows.uname + "</h2>"
                        // str += "<p>" + data.rows.body + "</p>"

                        // console.log(`<div>${data.rows.uimage}</div>`)

                        // m_img += "<img src='images/give_b.png'>"

                        // $("#conment").prepend(str)
                        // $("#c_img").prepend(m_img)
                        // $("#huifu").prepend(m_img)
                        $("#main-body-reply").prepend(replyStr);
                        $(".input-comment").val(" ");
                        var conmentNumbers = parseFloat($("#conment-number").text()) + 1;
                        $("#conment-number").text(conmentNumbers)
                        layer.open({
                            content: "评论成功",
                            skin: 'msg',
                            time: 3
                        });
                    }
                })


            });

            //展示回复评论
            $(".comment-left-box i").click(function() {
                console.log('打开')
                if ($(this).hasClass("arrow-down")) {
                    console.log('展开')
                    $(this).removeClass("arrow-down").addClass("arrow-up").parent().parent().find(
                        ".comment-huifu-box").show();
                } else {
                    console.log('关闭')
                    $(this).removeClass("arrow-up").addClass("arrow-down").parent().parent().find(
                        ".comment-huifu-box").hide();
                }

            });

            //点击评论
            $(".video-bottom-input").click(function() {
                $('.comment-info-box').slideDown(300);
                $('.box-curtain').show();
                $(".input-comment").focus();
                $(".input-comment").placeholder = '留下你的精彩评论吧~~~~';
                $(".input-comment").id = '';
            });
            //点击评论
            $(".BindComment").click(function() {
                $('.comment-info-box').slideDown(300);
                $('.box-curtain').show();
            });

            //收藏
            $(".BindCollection").click(function() {
                if ($(".BindCollection").find("img").attr("src") == "images/collection.png") {
                    var uid = "<?php echo $uid ?>"
                    var aid = "<?php echo $web_id ?>"
                    var code = 1
                    $.ajax({
                        url: 'userfavorite.php',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            uid: uid,
                            aid: aid,
                            code: code
                        },
                        success: function(data) {
                            console.log(data)
                            if (data.code) {

                                layer.open({
                                    content: "收藏成功",
                                    skin: 'msg',
                                    time: 3
                                });
                                $(".BindCollection").find("img").attr("src",
                                    "images/collection_r.png");
                            }
                        }
                    })
                } else {
                    var uid = "<?php echo $uid ?>"
                    var aid = "<?php echo $web_id ?>"
                    var code = 0
                    $.ajax({
                        url: 'userfavorite.php',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            uid: uid,
                            aid: aid,
                            code: code
                        },
                        success: function(data) {
                            console.log(data)
                            if (data.code == 1) {

                                layer.open({
                                    content: "取消收藏成功",
                                    skin: 'msg',
                                    time: 3
                                });
                                $(".BindCollection").find("img").attr("src",
                                    "images/collection.png");
                            }
                        }
                    })
                }
            });

            // 评论点赞
            $("#main-body-reply").on('click', '.comment_link', function() {
                var c_id = $(this).attr('id')
                if ($(this).find("img").attr("src") == "images/give_b.png") {
                    //点赞
                    var code = 1;
                    $.ajax({
                        type: 'post',
                        url: 'conmentLike.php',
                        data: {
                            c_id: c_id,
                            code: code
                        },
                        dataType: 'json',
                        success: function(data) {
                            console.log(data)
                            if (data.code == 1) {
                                layer.open({
                                    content: "点赞成功",
                                    skin: 'msg',
                                    time: 3
                                });
                                $('.conment_like' + data.c_id + '').html(data.rows)
                            }
                        }
                    })
                    $(this).find("img").attr("src", "images/give_r.png");
                } else {
                    //取消点赞
                    $.ajax({
                        type: 'post',
                        url: 'conmentLike.php',
                        data: {
                            c_id: c_id
                        },
                        dataType: 'json',
                        success: function(data) {
                            if (data.code == 1) {
                                layer.open({
                                    content: "取消点赞",
                                    skin: 'msg',
                                    time: 3
                                });
                                $('.conment_like' + data.c_id + '').html(data.rows)
                            }
                        }
                    })
                    $(this).find("img").attr("src", "images/give_b.png");
                }
            })

            //点赞
            $(".BindGive").click(function() {
                if ($(".BindGive").find("img").attr("src") == "images/give.png") {
                    var id = "<?php echo $id ?>"
                    var u_id = "<?php echo $uid ?>"
                    var code = 1;
                    $.ajax({
                        url: 'like.php',
                        data: {
                            id: id,
                            u_id: u_id,
                            code: code
                        },
                        dataType: 'json',
                        type: 'post',
                        success: function(data) {
                            if (data.code == 1) {
                                $(".BindGive").find("img").attr("src", "images/give_r.png");
                                $("#tbd").text(data.rows);
                            }
                        }
                    })
                } else {
                    var id = "<?php echo $id ?>"
                    var u_id = "<?php echo $uid ?>"
                    var code = 0;
                    $.ajax({
                        url: 'like.php',
                        data: {
                            id: id,
                            u_id: u_id,
                            code: code
                        },
                        dataType: 'json',
                        type: 'post',
                        success: function(data) {
                            console.log(data);
                            if (data.code == 1) {
                                $(".BindGive").find("img").attr("src", "images/give.png");
                                $("#tbd").text(data.rows);
                            }
                        }
                    })
                }
            });

            //分享事件
            $(".share-info-box li").click(function() {
                switch ($(this).attr("data-type")) {
                    case 'wx':
                        console.log(6565656565, wx)
                        layer.open({
                            content: "这是分享微信",
                            skin: 'msg',
                            time: 3
                        });
                        break;
                    case 'pyq':
                        layer.open({
                            content: "这是分享朋友圈",
                            skin: 'msg',
                            time: 3
                        });
                        break;
                    case 'zf':
                        layer.open({
                            content: "这是分享转发",
                            skin: 'msg',
                            time: 3
                        });
                        break;
                    case 'qqhy':
                        layer.open({
                            content: "这是分享QQ好友",
                            skin: 'msg',
                            time: 3
                        });
                        break;
                    case 'wb':
                        layer.open({
                            content: "这是分享微博",
                            skin: 'msg',
                            time: 3
                        });
                        break;
                    case 'jb':
                        var u_id = "<?php echo $_SESSION['Member_info'][0]['id']; ?>";
                        var web_id = "<?php echo $rows[0]['id']; ?>";
                        $.ajax({
                            url: 'report_ajax.php',
                            data: {
                                'u_id': u_id,
                                'web_id': web_id
                            },
                            dataType: 'json',
                            type: 'post',
                            success: function(res) {
                                if (res.status == 'y') {
                                    return layer.open({
                                        content: res.info,
                                        skin: 'msg',
                                        time: 3
                                    });
                                } else {
                                    return layer.open({
                                        content: res.info,
                                        skin: 'msg',
                                        time: 3
                                    });
                                }
                            }
                        })
                        layer.open({
                            content: "这是分享举报",
                            skin: 'msg',
                            time: 3
                        });
                        break;
                    case 'sc':
                        layer.open({
                            content: "这是分享收藏",
                            skin: 'msg',
                            time: 3
                        });
                        break;
                    case 'bcdxc':
                        layer.open({
                            content: "这是分享保存到相册",
                            skin: 'msg',
                            time: 3
                        });
                        break;
                    case 'bgxq':
                        layer.open({
                            content: "这是分享不感兴趣",
                            skin: 'msg',
                            time: 3
                        });
                        break;
                    case 'fzlj':
                        var copy_url = new Clipboard('.fzlj');
                        layer.open({
                            content: "链接已复制",
                            skin: 'msg',
                            time: 3
                        });
                        break;
                }
            });

            //联系我事件
            $(".contact-info-box li").click(function() {
                if ($(this).attr("data-type") == 'dh' && (window.navigator.userAgent == 'AndroidNative' || window.navigator.userAgent == 'IosNative')) return false
                switch ($(this).attr("data-type")) {
                    case 'dh':
                        layer.open({
                            content: "这是联系我电话",
                            skin: 'msg',
                            time: 3
                        });
                        break;
                    case 'wx':
                        var clipboard = new Clipboard('.copy_wx');
                        layer.open({
                            content: "微信号已复制",
                            skin: 'msg',
                            time: 3
                        });
                        break;
                    case 'sx':
                        layer.open({
                            content: "这是联系我私信",
                            skin: 'msg',
                            time: 3
                        });
                        break;
                    case 'ydylt':
                        //layer.open({content:"这是联系我一对一聊天",skin:'msg',time:3});

                        layer.open({
                            type: 1,
                            title: '通话方式',
                            // area: '300px',
                            // area: ['200px','150px'],
                            shade: 0.8,
                            shadeClose: true,
                            // skin: 'yourclass',
                            content: $('#putWindow'),
                            // btn: ['确定', '取消'], //按钮组
                            // yes: function(index){
                            //     layer.close(index);
                            //     joinRTCRoom();
                            // }
                        });
                        break;
                }
            });

            //艾特插件
            $(".btn-video-mail").click(function() {
                $('.comment-info-box').slideDown(300);
                $('.box-curtain').show();
                $(".input-comment").focus();
                $(".comment-footer-box").addClass("mail").removeClass("feel");
                $('.mail-box').slideDown(300);
                $('.feel-box').slideUp(300);
                $(".btn_mail").addClass("cur").siblings().removeClass("cur");

            });

            //艾特插件
            $(".btn_mail").click(function() {
                if ($(this).hasClass("cur")) {
                    $(".comment-footer-box").removeClass("feel").removeClass("mail");
                    $('.mail-box').slideUp(300);
                    $(this).removeClass("cur");
                } else {
                    $(".comment-footer-box").addClass("mail");
                    $('.mail-box').slideDown(300);
                    $('.feel-box').slideUp(300);
                    $(this).addClass("cur").siblings().removeClass("cur");
                }
            })

            //表情插件
            $(".btn-video-smile").click(function() {
                $('.comment-info-box').slideDown(300);
                $('.box-curtain').show();
                $(".comment-footer-box").addClass("feel").removeClass("mail");
                $('.feel-box').slideDown(300);
                $('.mail-box').slideUp(300);
                $(".btn_smile").addClass("cur").siblings().removeClass("cur");
            });

            //表情插件
            $(".btn_smile").click(function() {
                if ($(this).hasClass("cur")) {
                    $(".comment-footer-box").removeClass("feel").removeClass("mail");
                    $('.feel-box').slideUp(300);
                    $(this).removeClass("cur");
                } else {
                    $(".comment-footer-box").addClass("feel");
                    $('.feel-box').slideDown(300);
                    $('.mail-box').slideUp(300);
                    $(this).addClass("cur").siblings().removeClass("cur");
                }
            });


            //显示分享插件
            $(".BindShare").click(function() {
                $('.share-info-box').slideDown(300);
                $('.box-curtain').show();
            });

            //显示联系我插件
            $(".BindContact").click(function() {
                $('.contact-info-box-act').show();
                $('.box-curtain').show();
            });
            $(".other_btn").click(function(){
                $('.other-box').show();
                $('.box-curtain').show();
            })

            //隐藏遮幕
            $(".box-curtain").click(function() {
                $('.box-curtain').hide();
                $('.share-info-box').slideUp(300);
                $('.comment-info-box').slideUp(300);
                $('.contact-info-box').hide();
                $(".other_con").hide();
            })

            $('.select-box').click(function() {
                $('.select-input').trigger("click")
                // console.log(1212122222222)
            })

            //提交保存前
            $('.save').click(function() {
                var placetitle = $('.title-input').attr('placeholder');
                var placedesc = $('.desc-input').attr('placeholder');
                var title = $('.title-input').val();
                var desc = $('.desc-input').val();
                var shareTitle = ''
                var shareDesc = ''
                if (title == '' || title.replace(/(^s*)|(s*$)/g, "").length == 0) {
                    if (placetitle == '') {
                        layer.open({
                            content: '请先输入标题！',
                            skin: 'msg',
                            time: 2 //2秒后自动关闭
                        });
                    } else {
                        $('.title-input').val(placetitle);
                        shareTitle = placetitle
                    }
                } else {
                    shareTitle = title
                }

                if (desc == '' || desc.replace(/(^s*)|(s*$)/g, "").length == 0) {
                    if (placedesc == '') {
                        layer.open({
                            content: '请先输入描述！',
                            skin: 'msg',
                            time: 2 //2秒后自动关闭
                        });
                    } else {
                        $('.desc-input').val(placedesc);
                        shareDesc = placedesc
                    }
                } else {
                    shareDesc = desc
                }

                if ($('#fileImg').attr("src") == '') {
                    layer.open({
                        content: '请先上传图片！',
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    return false;
                }

                //提交接口 判断是否APP
                if(window.navigator.userAgent == 'AndroidNative'){
                    // javascript:android.indexShare(_imgURL, title, desc, _link);
                    dsBridge.call("videoShare", {
                        img: _imgURL,
                        title: shareTitle,
                        content:shareDesc,
                        link: "https://5p8.fyh5p8.com/xiaochengxu/" + _link
                    });
                } else if (window.navigator.userAgent == 'IosNative') {
                    // window.webkit.messageHandlers.indexShare.postMessage({img: _imgURL, title: title, content:desc, link:_link});
                    dsBridge.call("videoShare", {
                        img: _imgURL,
                        title: shareTitle,
                        content:shareDesc,
                        link: "https://5p8.fyh5p8.com/xiaochengxu/" + _link
                    });
                } else {
                    loadData();
                }
            });
        });

        //分享点击图片选择
        function upFile() {
            $('#file').click();
        }

        //图片改变
        function changepic(obj) {
            // $('#fileImg').removeClass('fileIcon').addClass('newImg');
            if (!obj.files || !obj.files[0]) {
                return;
            }

            // 找到canvas,准备画图
            var canvas = document.getElementById('canvas');
            var context = canvas.getContext('2d');


            file = obj.files[0];
            console.log(file)
            // console.log('file', file)



            var reader = new FileReader();
            reader.readAsDataURL(file);
            reader.onload = function(evt) {
                // console.log(reader.result);
                // if (reader.result.size > 2048) {
                //     layer.open({
                //         content: '文件大小需在2M以内！',
                //         skin: 'msg',
                //         time: 2 //2秒后自动关闭
                //     });
                // }

                //获取的是图片的base64代码
                var replaceSrc = evt.target.result;
                //定义一个Image对象
                var image = new Image();
                image.src = replaceSrc;
                image.onload = function() {
                    //获取的是图片的base64代码
                    var replaceSrc = evt.target.result;

                    //定义一个Image对象
                    var image = new Image();
                    image.src = replaceSrc;
                    image.onload = function() {

                        // 加载完毕后获取图片的原始尺寸
                        var origin_width = this.width;
                        var origin_height = this.height;
                        // console.log("原始图片宽度：" + origin_width + " px");
                        // console.log("原始图片高度：" + origin_height + " px");
                        // 设置最大允许宽高,根据需求自己设置,值越大,图片大小越大
                        var max_width = 100;
                        var max_height = 100;

                        // 最终宽高
                        target_width = origin_width;
                        target_height = origin_height;
                        if (origin_width > max_width || origin_height > max_height) {
                            if (origin_width / origin_height > max_width / max_height) {
                                // 更宽，按照宽度限定尺寸
                                target_width = max_width;
                                target_height = Math.round(max_width * (origin_height / origin_width));
                            } else {
                                target_height = max_height;
                                target_width = Math.round(max_height * (origin_width / origin_height));
                            }
                        }

                        canvas.width = target_width;
                        canvas.height = target_height;
                        // 绘画到画布上
                        context.drawImage(image, 0, 0, target_width, target_height);

                        //此处得到的是blob对象,blob对象是在ie10及以上才兼容,在ios8_1_1上和iphoneSE上有兼容问题
                        // canvas.toBlob(function (res) {
                        //     console.log(res);
                        //     formData.append("file", res);
                        //     // formData.append("openid", openid);
                        // });

                        // 读取canvas的数据
                        var result = canvas.toDataURL();


                        var arr = result.split(','),
                            mime = arr[0].match(/:(.*?);/)[1], // 转成blob
                            bstr = atob(arr[1]),
                            n = bstr.length,
                            u8arr = new Uint8Array(n);
                        while (n--) {
                            u8arr[n] = bstr.charCodeAt(n);
                        }
                        aaa = new window.File([new Blob([u8arr], {
                            type: mime
                        })], 'test.jpeg', {
                            type: 'image/jpg,image/jpeg,image/png,image/PNG'
                        }) // 转成file
                        console.log('00', aaa)
                        // console.log('000formData:', formData)
                        // 得到的结果是base64位的字符串,拿到压缩后的值通过网络请求交给后台处理...
                        // 如果是blob对象,需要通过FormData对象发送
                        console.log('最终图片链接', result); //最终图片链接

                        //最终图片宽高
                        //console.log("压缩后图片宽度：" + target_width + " px");
                        //console.log("压缩后图片高度：" + target_height + " px");
                        // 再将获取值赋给img标签
                        // $('#fileImg').attr("src", result);

                        var formData = new FormData();
                        formData.append("file", aaa);
                        sendToSever(formData);
                    }
                }
            }


        }

        //获取图片文件名
        function getFileName(o) {
            var pos = o.lastIndexOf("\\");
            return o.substring(pos + 1);
        }

        //上传图片
        function sendToSever(formData) {
            $.ajax({
                url: 'fileup_img.php',
                type: "post",
                data: formData,
                dataType: 'json',
                processData: false, // 使数据不做处理
                contentType: false, // 不要设置Content-Type请求头
                timeout: 10000,
                beforeSend: function() {
                    lid = layer.open({
                        type: 2,
                        content: '提交中...',
                        shadeClose: false
                    });
                },
                success: function(res) {
                    if (res.status == 'y') {
                        layer.open({
                            content: res.info,
                            skin: 'msg',
                            time: 2 //2秒后自动关闭
                        });

                        _imgURL = "https://5p8.fyh5p8.com/xiaochengxu/" + res.src;
                        $('#fileImg').attr("src", _imgURL);
                    } else {
                        layer.open({
                            content: res.info,
                            skin: 'msg',
                            time: 2 //2秒后自动关闭
                        });
                    }
                    // console.log(_img);
                },
                complete: function() {
                    layer.close(lid);
                },
                error: function(XMLHttpRequest, textStatus) {
                    layer.close(lid);
                    if ('timeout' == textStatus) {
                        alert('请求接口超时！');
                    } else {
                        alert(JSON.stringify(XMLHttpRequest))
                    }
                }
            });
        }

        //保存提交
        function loadData() {
            var title = $('.title-input').val();
            var desc = $('.desc-input').val();

            var id = "<?php echo $rows[0]['id']; ?>";
            var u_id = "<?php echo $_SESSION['Member_info'][0]['id']; ?>";

            // console.log(id, desc, title, share_img, u_id);
            $.ajax({
                url: 'share.php',
                type: "post",
                data: {
                    'img_url': _imgURL,
                    'desc': desc,
                    'title': title,
                    'id': id,
                    'u_id': u_id,
                    'link': _link
                },
                dataType: 'json',
                timeout: 10000,
                beforeSend: function() {
                    lid = layer.open({
                        type: 2,
                        content: '提交中...',
                        shadeClose: false
                    });
                },
                success: function(res) {
                    console.log(res);
                    layer.close(lid);
                    // alert(res)
                    if (res.status == 'y') {
                        layer.open({
                            type: 1,
                            title: false //不显示标题
                                ,
                            offset: "t" //右上角弹出
                                // ,id: 'layerDemo' + type //防止重复弹出
                                ,
                            content: "<div id='sharebox' style='padding: 30px 20px;'><span style='display: inline-block;margin-right: 10px;'>保存成功！确认后，点击右上角去分享</span></div>",
                            btn: '确认',
                            btnAlign: 'c' //按钮居中
                                ,
                            shade: 0.8,
                            shadeClose: false,
                            yes: function() {
                                layer.closeAll();
                                window.location.reload(); //页面重载
                            }
                        });
                    } else {
                        layer.open({
                            content: res.info,
                            skin: 'msg',
                            time: 2 //2秒后自动关闭
                        });
                    }
                },
                complete: function() {
                    //layer.close(lid);
                },
                error: function(XMLHttpRequest, textStatus) {
                    layer.close(lid);
                    if ('timeout' == textStatus) {
                        alert('请求接口超时！');
                    } else {
                        alert('系统错误，请刷新重试！')
                    }
                }
            });

        }

        function getaddre() {
            var x = "<?php echo $rows[0]['lat']; ?>";
            var y = "<?php echo $rows[0]['lng']; ?>";

            var map, geolocation;
            map = new AMap.Map('allmap');
            map.plugin('AMap.Geolocation', function() {
                geolocation = new AMap.Geolocation({
                    enableHighAccuracy: true //是否使用高精度定位，默认:true
                });
                geolocation.getCurrentPosition();
                AMap.event.addListener(geolocation, 'complete', function(point) {

                    var lnglatXY = y + "," + x; //已知点坐标
                    // alert(lnglatXY);
                    map.plugin('AMap.Geocoder', function() {
                        var geocoder = new AMap.Geocoder();
                        geocoder.getAddress(lnglatXY, function(status, result) {
                            if (status === 'complete' && result.info === 'OK') {
                                var address = result.regeocode.formattedAddress;
                                var obj = result.regeocode.addressComponent;
                                address = address.replace(obj.province, '');
                                address = address.replace(obj.district, '');
                                address = address.replace(obj.city, '');
                                var lng = point.position.lng;
                                var lat = point.position.lat;
                                var p1 = [y, x];
                                var p2 = [point.position.lng, point.position.lat];
                                var dis = AMap.GeometryUtil.distance(p1, p2);
                                var danwei;
                                if (dis > 1000) {
                                    dis = dis / 1000;
                                    dis = Math.round(dis);
                                    danwei = '公里';
                                } else {
                                    dis = Math.round(dis);
                                    danwei = '米';
                                }
                                $("#address").html(address);
                                $(".juli").html(dis + danwei);
                                // console.log(address);
                                console.log(address);
                                $("input[name='lng']").attr('value', point.position.lng);
                                $("input[name='lat']").attr('value', point.position.lat);
                                console.log(point.position.lng, point.position.lat);
                            }
                        });
                    });
                });
            });

        }

        //加入一对一房间
        function joinRTCRoom(type) {
            var roomNumber = '5p' + '<?php echo $rows[0]['u_id'] ?>'; //房间号
            // console.log(roomNumber)
            var cellphone = '<?php echo $row_member[0]['mobile'] ?>'; //商家手机号
            var openid = '<?php echo $row_member[0]['openid'] ?>'; //商户openid
            var userid = '5p8' + '<?php echo $_SESSION['Member_info'][0]['id'] ?>'; //用户

            // if(roomNumber == '' || roomNumber.replace(/(^s*)|(s*$)/g, "").length == 0){
            //     layer.open({content:"请输入房间号！",skin:'msg',time:2});
            //     return false;
            // }
            if (userid == '' || userid == null) {
                layer.open({
                    content: "无用户！",
                    skin: 'msg',
                    time: 2
                });
                return false;
            }
            layer.closeAll();
            if (window.navigator.userAgent == 'AndroidNative') {
                // javascript:android.openRTCActivity(type,'<?php echo $rows[0]['u_id'] ?>');
                dsBridge.call("openRTCActivity", {type: type, shopId: '<?php echo $rows[0]['u_id'] ?>'});
            } else if (window.navigator.userAgent == 'IosNative') {
                dsBridge.call("openRTCActivity", {type: type, shopId: '<?php echo $rows[0]['u_id'] ?>'});
                // window.webkit.messageHandlers.openRTCActivity.postMessage({
                //     type: type,
                //     id: '<?php echo $rows[0]['u_id'] ?>',
                // });
            } else {
                //提交接口
                $.ajax({
                    url: 'qiniu_ajax.php', //后台补充接口
                    type: "post",
                    data: {
                        'roomNumber': roomNumber,
                        'userid': userid
                    },
                    dataType: 'json',
                    timeout: 10000,
                    beforeSend: function() {
                        // lid = layer.open({
                        //     type: 2,
                        //     content: '提交中...',
                        //     shadeClose: false
                        // });
                    },
                    success: function(res) {
                        console.log(res, '房间提交返回');
                        if (res.status == 'y') {
                            $.ajax({
                                url: 'Sms.php', //后台补充接口
                                type: "post",
                                data: {
                                    'cellphone': '16605126035',
                                    'room_num': roomNumber,
                                    'openid': openid,
                                    'type': type
                                },
                                dataType: 'json',
                                timeout: 10000,
                                beforeSend: function() {

                                },
                                success: function(res) {



                                }
                            })
                            var roomToken = res.data; //获取到roomToken
                            setTimeout(() => {
                                window.location = 'qnRTC.html?roomToken=' + roomToken + '&type=' +
                                    type;
                            }, 1000);
                        } else {
                            layer.open({
                                content: res.info,
                                skin: 'msg',
                                time: 2
                            });
                        }


                    },
                    complete: function() {
                        //layer.close(lid);
                    },
                    error: function(XMLHttpRequest, textStatus) {
                        layer.close(lid);
                        if ('timeout' == textStatus) {
                            alert('请求接口超时！');
                        } else {
                            alert('系统错误，请刷新重试！')
                        }
                    }
                });
            }
        }
        $('.toPhone').click(function() {
            if(window.navigator.userAgent == 'AndroidNative'){
                // javascript:android.callPhone('<?php echo $row_member[0]['mobile'] ?>');
                dsBridge.call("callPhone", {phone: '<?php echo $row_member[0]['mobile'] ?>'});
            } else if (window.navigator.userAgent == 'IosNative') {
                // window.webkit.messageHandlers.callPhone.postMessage({phone: '<?php echo $row_member[0]['mobile'] ?>'});
                dsBridge.call("callPhone", {phone: '<?php echo $row_member[0]['mobile'] ?>'});
            }
        })
        function report_ajax(obj){
            if(obj == 'jubao'){
                var feedback = '举报反馈';
            }else if (obj == 'lahei') {
                var feedback = '拉黑反馈';
            }else if (obj == 'tousu') {
                var feedback = '投诉反馈';
            }
            $(".other_con").find("h4").html(feedback);
            $(".other_con").find("h4").attr('data_obj',obj);
            $(".other_con").show();
            $('.box-curtain').show();
        }

        $(".feedback").click(function(){
            var con = $('textarea[name="other_con"]').val();
            var obj = $('.other_con').find("h4").attr("data_obj");
            if(con == ''){alert('请输入反馈内容');return;};
            $(".other_con").hide();
            $(".other-box").hide();
            $('.box-curtain').hide();
            $.ajax({
                url: 'feedback_ajax.php', //后台补充接口
                type: "post",
                data: {'con': con,'obj':obj},
                dataType: 'json',
                success: function(res) {
                    if(res.states == 'y'){
                        alert(res.info);
                    }
                }
            })
        })


    </script>

</body>

</html>
